package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CcsEnableAppointment;
import com.ruoyi.system.service.ICcsEnableAppointmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 可预约Controller
 * 
 * @author ruoyi
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/system/enableAppointment")
public class CcsEnableAppointmentController extends BaseController
{
    @Autowired
    private ICcsEnableAppointmentService ccsEnableAppointmentService;

    /**
     * 查询可预约列表
     */
    @PreAuthorize("@ss.hasPermi('system:enableAppointment:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcsEnableAppointment ccsEnableAppointment)
    {
        startPage();
        List<CcsEnableAppointment> list = ccsEnableAppointmentService.selectCcsEnableAppointmentList(ccsEnableAppointment);
        return getDataTable(list);
    }

    /**
     * 导出可预约列表
     */
    @PreAuthorize("@ss.hasPermi('system:enableAppointment:export')")
    @Log(title = "可预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcsEnableAppointment ccsEnableAppointment)
    {
        List<CcsEnableAppointment> list = ccsEnableAppointmentService.selectCcsEnableAppointmentList(ccsEnableAppointment);
        ExcelUtil<CcsEnableAppointment> util = new ExcelUtil<CcsEnableAppointment>(CcsEnableAppointment.class);
        util.exportExcel(response, list, "可预约数据");
    }

    /**
     * 获取可预约详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:enableAppointment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccsEnableAppointmentService.selectCcsEnableAppointmentById(id));
    }

    /**
     * 新增可预约
     */
    @PreAuthorize("@ss.hasPermi('system:enableAppointment:add')")
    @Log(title = "可预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcsEnableAppointment ccsEnableAppointment)
    {
        return toAjax(ccsEnableAppointmentService.insertCcsEnableAppointment(ccsEnableAppointment));
    }

    /**
     * 修改可预约
     */
    @PreAuthorize("@ss.hasPermi('system:enableAppointment:edit')")
    @Log(title = "可预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcsEnableAppointment ccsEnableAppointment)
    {
        return toAjax(ccsEnableAppointmentService.updateCcsEnableAppointment(ccsEnableAppointment));
    }

    /**
     * 删除可预约
     */
    @PreAuthorize("@ss.hasPermi('system:enableAppointment:remove')")
    @Log(title = "可预约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccsEnableAppointmentService.deleteCcsEnableAppointmentByIds(ids));
    }
}
